package Offer;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

// 用两个栈实现队列
public class Offer09CQueue {

    Deque<Integer> stack1;
    Deque<Integer> stack2;

    public Offer09CQueue() {
        stack1=new LinkedList<>();
        stack2=new LinkedList<>();
    }

    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        if(stack2.isEmpty()){
            while (!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        if(stack2.isEmpty()){
            return -1;
        }else{
            return stack2.pop();
        }
    }
}
